package com.esun.service.mq.enums;

import com.esun.dao.eo.BaseEo;
import com.esun.dao.eo.ExampleEo;
import org.apache.commons.lang.StringUtils;

/**
 * mongodb表与实体映射枚举
 * @author John.xiao
 * @date 2021/9/2 10:35
 */
public enum BaseEoEnum {
	EXAMPLE("example", ExampleEo.builder().build())
	;

	private String collection;

	private BaseEo entity;

	BaseEoEnum(String collection,BaseEo entity){
		this.collection = collection;
		this.entity = entity;
	}

	public static BaseEoEnum match(String collection){
		BaseEoEnum[] baseEoEnums =  BaseEoEnum.values();
		for (BaseEoEnum value : baseEoEnums) {
			if (StringUtils.equals(value.collection, collection)){
				return value;
			}
		}
		return null;
	}

	public String getCollection() {
		return collection;
	}

	public void setCollection(String collection) {
		this.collection = collection;
	}

	public BaseEo getEntity() {
		return entity;
	}

	public void setEntity(BaseEo entity) {
		this.entity = entity;
	}
}
